//
//  NewInMechanismCellModel.m
//  EnvironmentalProtection
//
//  Created by HCreater on 2018/11/20.
//  Copyright © 2018年 HCreater. All rights reserved.
//

#import "NewInMechanismCellModel.h"

#import "MechanismInfoData.h"

@interface NewInMechanismCellModel ()

@property (nonatomic, readwrite, copy) NSString* name;
@property (nonatomic, readwrite, copy) NSString* content;
@property (nonatomic, readwrite, copy) NSString* avatarImgurl;

@end

@implementation NewInMechanismCellModel

- (instancetype)initWithData:(id)data cellHeight:(CGFloat)cellHeight
{
    self = [super init];
    if (self)
    {
        _data = data;
        
        /// cellHeight+2（2容错）
        _cellHeight = MHUIScaleValue(cellHeight)+2;
        
        @weakify(self);
        [[RACObserve(self, data) distinctUntilChanged] subscribeNext:^(id x)
         {
             @strongify(self);
             
             MechanismInfoData* mInfoData = x;
             
             //TODO:缺失参数
             self.name = mInfoData.name;
             self.content = mInfoData.service!=nil ? [NSString stringWithFormat:@"服务内容：%@", mInfoData.service] : @"";
             self.avatarImgurl = mInfoData.headimg;
         }];
    }
    
    return self;
}

@end
